
<template>
  <el-dialog
    title="充值卡查看"
    :visible.sync="dialogVisible"
    width="50%"
    destroy-on-close
    append-to-body
    custom-class="k-dilaog"
    class="z-dialog"
    @closed="closedEvent">
    <el-form ref="form" :model="form" label-width="120px">
      <el-form-item label="卡号" required>
        <el-input v-model="form.seqNo" disabled></el-input>
      </el-form-item>
      <el-form-item label="卡密" required>
        <el-input v-model="form.pwd" disabled></el-input>
      </el-form-item>
      <el-form-item label="充值点数" required>
        <el-input v-model="form.points" disabled></el-input>
      </el-form-item>
      <el-form-item label="充值状态" required>
        <el-input v-model="form.statusLabel" disabled></el-input>
      </el-form-item>
      <el-form-item label="创建时间" required>
        <el-input v-model="form.createTime" disabled></el-input>
      </el-form-item>
      <el-form-item label="充值时间" required>
        <el-input v-model="form.startTime" disabled></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="clickSureBtn" :loading="loading" :disabled="form.status!=='01'">作 废</el-button>
     <el-button @click="dialogVisible = false">关 闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
import request from '@/utils/request';

export default {
  name:"rechargeCardDetailDialog",
  data(){
    return{
      dialogVisible:false,
      loading:false,
      form:{
        points:null,
        numberOfCard:null,
        effectiveDays:null,
      },
      callBack:null,
      pageType:0,//0充值卡生成1充值卡查看
      id:null,
    }
  },
  methods:{
    openDiaolog(pageType,id,block){
      this.pageType = pageType;
      this.id = id;
      this.callBack = block;
      this.dialogVisible = true;
      if (pageType === 1){//查看
        this.requestDataDetail();
      }
    },
    clickSureBtn(){
      this.requestDataDel(this.id);
    },
    closedEvent(){
      this.form = {};
    },
    //网络-详情
    requestDataDetail(){
      request({
        url:`/card_info/${this.id}`,
        method:'get',
        params: {}
      }).then(response =>{
        this.form = response.data;
      })
    },
    //网络-作废
    requestDataDel(id){
      this.loading = true;
      request({
        url:`/card_info/`,
        method:'put',
        data: {
          id:id,
          status:"03",
        },
      }).then(response =>{
        this.$message.success(response.msg);
        this.dialogVisible = false;
      }).finally(()=>{
        this.loading = false;
      })
    },
  }
}

</script>

<style scoped>

</style>
